package mapper.FleasMarketManagement;

import entity.FleasMarket;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.LinkedHashMap;
import java.util.List;

@Repository
public interface FleasMarketMapper {

    @Select("select FleasMarket.*,User.name as publisherName,User.icon as userIcon from FleasMarket,User where FleasMarket.publisher = User.userId")
    public List<LinkedHashMap<String,Object>> findFleasMarketItems();

    @Insert("Insert into FleasMarket(name1,describe1,releaseTime,publisher,price) values(#{name},#{describe},#{releaseTime},#{publisher},#{price})")
    public int issue_fleasMarket(FleasMarket fleasMarket);

    @Select("select shopId from FleasMarket where FleasMarket.publisher = #{userId} and FleasMarket.releaseTime = #{time}")
    public int findItemsShopId(@Param("userId") String userId,@Param("time") String time);

    @Update("update FleasMarket set icon = #{icon} where shopId = #{shopId};")
    public int updateFleasIcon(@Param("icon") String icon, @Param("shopId") String shopId);
}
